<template>
  <div id="app">
    <img src="./assets/logo.png">
    <div>
      <div>
        <button @click="goBack">返回</button>
        <button @click="goNext">前进</button>
        <button @click="goHome">返回首页</button>
      </div>
      <!-- router-link:相当于a标签 -->
      <router-link to="/">首页</router-link> |
      <router-link to="/Hi">Hi</router-link> |
      <!-- url传递参数 :绑定参数 -->
      <router-link to="/params/:name/:age">传参</router-link> |
      <router-link to="/gohome">重定向首页</router-link> |
      <router-link to="/goparams/:name/:age">带参重定向</router-link> |
      <router-link to="/goHi">Hi别名</router-link> |
    </div>
    <!-- 根据url渲染的组件,必须要有 -->
    <!-- 多路由区域 -->
    
     <!-- mode: 动画模式,默认是in-out ,即先进入再消失 -->
    <transition name="fade" mode="out-in">   
        <router-view/>
        <router-view name="view1" style="width:50%;height:300px;float:left;background:blue;"/>
        <router-view name="view2" style="width:50%;height:300px;float:left;background:red;"/>
    </transition>
  </div>
</template>

<script>
export default {
  name: 'App',
  methods:{
    goBack(){
      this.$router.go(-1);
    },
    goNext(){
      this.$router.go(1);
    },
    goHome(){
      this.$router.push("/");
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.fade-enter{
  opacity:0;  /* opacity:透明度,0:完全透明,1 ,完全不透明*/
}
.fade-enter-active{
  transition:opacity .5s;
}
.fade-leave{
  opacity:1;
}
.fade-leave-active{
  opacity:0;
  transition: opacity .5s;
}
</style>
